Skip to content

fix(cmind): handle list meta.path in GraphQueryEngine search - #105

Open
MattThomas-fastino wants to merge 1 commit into
microsoft:mainfrom
MattThomas-fastino:fix/graph-query-list-meta-path
Open

MattThomas-fastino wants to merge 1 commit into
microsoft:mainfrom
MattThomas-fastino:fix/graph-query-list-meta-path

Conversation

@MattThomas-fastino

Copy link
Copy Markdown

Summary

search_rpg crashes with 'list' object has no attribute 'lower' on any graph that has been through run_update_rpg.

RPGService.enrich_from_code (called with align_only=True from run_update_rpg) still runs _enrich_group_paths and _enrich_l1_paths. When a feature group spans more than one file, or a functional area spans more than one directory, those steps store meta.path as a sorted list. The rest of the package already accepts that shape (paths = p if isinstance(p, list) else [p] in service.py and models.py). GraphQueryEngine was the reader that still assumed a string.

Two consequences in _search_rpg_tree:

  • ":" in meta_path on a list is a membership test, not a substring test, so the path is left as a list.
  • file_part.lower() then raises AttributeError.

The same list also crashes _normalize_path via .startswith when _dep_graph_code_dir is set. Search, node detail, and tree listing all go through that helper.

scope="code" was unaffected. scope="all" (the default) was not, because it also searches the feature tree.

Fix

  • Match the query against every entry of a list path, using the same isinstance(..., list) idiom as the writers.
  • Normalise a list path entry by entry in _normalize_path, so the legacy code-dir prefix is stripped from each one. A list stays a list in the result.

Reproduction

from rpg.graph_query import GraphQueryEngine

rpg = {"root": {"id": "repo", "name": "brain", "node_type": "repo", "meta": {"path": "."},
    "children": [{"id": "area", "name": "Inference Serving", "node_type": "functional_area",
        "meta": {"path": ["services/inference", "api/inference"]}, "children": []}]}}
engine = GraphQueryEngine(rpg, {"nodes": {}, "edges": []})
engine.search("inference", scope="feature")
# AttributeError: 'list' object has no attribute 'lower'

Tests

CoderMind/tests/test_graph_query_meta_path.py fails on main with the .lower() and .startswith errors, and passes with this change. test_path_format.py is unchanged and still passes.

Made with Cursor

enrich_from_code stores a list when a feature group or area spans more
than one file. Search assumed a string and crashed on .lower().

Co-authored-by: Cursor <cursoragent@cursor.com>
@MattThomas-fastino

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant